#include <iostream>
#include <vector>
using namespace std;

int n;
int a;
int b;
int nums[203];
bool v[203];
int ans;
void dfs(int a,int cnt){
    if(a == b){
        ans = min(ans,cnt);
        return;
    }
    if(cnt >= ans) return;
    v[a] = 1;
    if(a+nums[a] <=n && !v[a+nums[a]]) dfs(a+nums[a], cnt+1);
    if(a-nums[a] >=1 && !v[a-nums[a]]) dfs(a-nums[a], cnt+1);
    v[a] = 0;
}

int main(){
    cin >> n;
    cin >> a;
    cin >> b;
    for(int i=1;i<=n;i++) cin >> nums[i];
    ans = 0x3f3f3f3f;
    dfs(a,0);
    cout << ans << endl;
    return 0;
}